<template>
  <view class="page-module__advert">
    <view v-for="(item, index) in datas.list" :key="index" class="item" @click="onAdvert(item)">
      <edu-image :src="item.url" height="124rpx" border-radius="16"></edu-image>
    </view>
  </view>
</template>

<script>
export default {
  name: 'Advert',
  props: {
    datas: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {}
  },
  methods: {
    onAdvert(item) {
      if (item.type == 1 && item.course_id) {
        this.$u.route('/pageCourse/course/details', {
          id: item.course_id,
        })
      } else if (item.type == 2 && item.href) {
        // #ifdef H5
        window.open(item.href)
        // #endif
        // #ifdef APP-PLUS
        plus.runtime.openURL(item.href)
        // #endif
      }
    },
  },
}
</script>

<style lang="scss" scoped>
.page-module__advert {
  margin-bottom: 48rpx;
  padding: 0 30rpx;
  display: grid;
  grid-template-columns: repeat(2, minmax(0px, 1fr));
  gap: 16rpx 22rpx;
  .item {
    grid-column: span 1 / span 1;
  }
}
</style>
